package com.suxin.webflux.service;

import com.suxin.webflux.domain.User;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;

public class Client {

    public static void main(String[] args) {

        WebClient webClient = WebClient.create("http://127.0.0.1:56516");

        Flux<User> userFlux = webClient.get().uri("/user/all")
                .accept(MediaType.APPLICATION_JSON)
                .retrieve().bodyToFlux(User.class);

        userFlux.map(User::getName).buffer()
                .doOnNext(System.out::println).blockFirst();
    }

}
